//egret example 1
precision lowp float;
varying vec2 vTextureCoord;
varying vec4 vColor;
uniform sampler2D uSampler;

uniform float iTime;

const float PI = 3.14159265358979323846264;

void main(void) {
	vec2 uv = vTextureCoord.xy;
	if (iTime >= 1.0){
		gl_FragColor = vec4(0,0,0,0);
		return;
	}

	float angle = iTime * PI;
	
	//float dot1 = dot(vec2(1-0.5,0-0.5),vec2(uv.x-0.5,uv.y-0.5));
	//float dot2 = dot(vec2(0-0.5,1-0.5),vec2(uv.x-0.5,uv.y-0.5));
	float l = atan(0.0 - 0.5, 1.0 - 0.5);
	float r = atan(1.0 - 0.5, 0.0 - 0.5);

	float a = atan(uv.y - 0.5, uv.x - 0.5);
	
	float d = 0.0;
	if (a >= l && a < r){
		d = a - l;	
	}
	else {
		d = a - r;
		if( d < 0.0){
			d += 2.0 * PI;
		}
	}

	if (d <= angle){
		gl_FragColor = vec4(0,0,0,0);
		return;
	}

	vec4 fg = texture2D(uSampler, vTextureCoord);
	gl_FragColor = fg * vColor;
}
